package com.cetcs.kmga.dataManager.util;

import com.cetcs.kmga.dataManager.entity.dataManager.RiskEvent;
import com.cetcs.kmga.dataManager.entity.dataManager.vi.RiskEventMqVi;
import com.cetcs.kmga.dataManager.entity.device.DeviceInfo;
import com.cetcs.kmga.dataManager.entity.device.DeviceManufacturerIdentifier;
import com.cetcs.kmga.dataManager.entity.device.DeviceTypeIdentifier;
import com.cetcs.kmga.dataManager.entity.device.vo.DeviceInfoVo;
import com.cetcs.kmga.dataManager.entity.device.vo.KeyAndValueVo;
import org.apache.commons.beanutils.BeanUtils;

public class Entity2Vo {
    /**
     * DeviceInfo2DeviceInfoVo
     *
     * @param deviceInfo
     * @return
     */
    public static DeviceInfoVo DeviceInfo2DeviceInfoVo(DeviceInfo deviceInfo) {
        DeviceInfoVo deviceInfoVo = new DeviceInfoVo();
        deviceInfoVo.setDevice_id(deviceInfo.getId());
        deviceInfoVo.setDevice_name(deviceInfo.getName());
        deviceInfoVo.setDevice_ip(deviceInfo.getIp());
        deviceInfoVo.setDevice_mac(deviceInfo.getMac());
        deviceInfoVo.setDevice_vers(deviceInfo.getVers());
        deviceInfoVo.setDevice_type(deviceInfo.getType());
        deviceInfoVo.setDevice_location(deviceInfo.getLocation());
        deviceInfoVo.setDevice_adminName(deviceInfo.getAdminName());
        deviceInfoVo.setDevice_adminPhone(deviceInfo.getAdminPhone());
        deviceInfoVo.setDevice_userName(deviceInfo.getRegUsr());
        deviceInfoVo.setDevice_userPassword("");
        deviceInfoVo.setDevice_manuf(deviceInfo.getManuf());
        deviceInfoVo.setStatus(Integer.parseInt(deviceInfo.getStatus()));
//        if(Integer.parseInt(deviceInfo.getStatus()) > 1){
//            //正常
//            deviceInfoVo.setStatus(Integer.parseInt(deviceInfo.getStatus())-1);
//        }else{
//            //离线
//            deviceInfoVo.setStatus(Integer.parseInt(deviceInfo.getStatus()));
//        }

        deviceInfoVo.setDevice_url(deviceInfo.getUrl());
        return deviceInfoVo;
    }


    /**
     * DeviceType2KeyAndValueVo
     *
     * @param deviceTypeIdentifier
     * @return
     */
    public static KeyAndValueVo DeviceType2KeyAndValueVo(DeviceTypeIdentifier deviceTypeIdentifier) {
        KeyAndValueVo keyAndValueVo = new KeyAndValueVo();
        keyAndValueVo.setKey(String.valueOf(deviceTypeIdentifier.getId()));
        keyAndValueVo.setValue(deviceTypeIdentifier.getType());
        return keyAndValueVo;
    }

    /**
     * DeviceManufacturerIdentifier2KeyAndValueVo
     *
     * @param deviceManufacturerIdentifier
     * @return
     */
    public static KeyAndValueVo DeviceManufacturerIdentifier2KeyAndValueVo(DeviceManufacturerIdentifier deviceManufacturerIdentifier) {
        KeyAndValueVo keyAndValueVo = new KeyAndValueVo();
        keyAndValueVo.setKey(String.valueOf(deviceManufacturerIdentifier.getId()));
        keyAndValueVo.setValue(deviceManufacturerIdentifier.getManufacturer());
        return keyAndValueVo;
    }


}
